package com.example.xianji.adapter;

import com.example.xianji.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Birthday_Adapter extends BaseAdapter {

	private Context mContext;
	private String[]group;

	private int select_postion=-1;



		public Birthday_Adapter(Context mContext, String[] group) {
		super();
		this.mContext = mContext;
		this.group = group;
		
	}

		@Override
		public int getCount() {
			return group.length;
		}

		@Override
		public Object getItem(int arg0) {
			return arg0;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			Holder holder;
			if(convertView==null){
				holder=new Holder();
				convertView=View.inflate(mContext, R.layout.place_listview_item, null);
				holder.linear_layout=(LinearLayout) convertView.findViewById(R.id.linear_layout);
				
				holder.place_text=(TextView) convertView.findViewById(R.id.place_text);
				
				convertView.setTag(holder);
			}
			holder=(Holder) convertView.getTag();
			if(select_postion==position){
				
				holder.linear_layout.setBackgroundColor(mContext.getResources().getColor(R.color.grayF2));
				
			}else{
				
				holder.linear_layout.setBackgroundColor(mContext.getResources().getColor(R.color.white));	
			}
			holder.place_text.setText(group[position]);
			
			return convertView;
		}
	class Holder{
		TextView place_text;
		LinearLayout linear_layout;
	}
		
		public void setPosition(int position){
			
			select_postion=position;
		}
}
